<%@ page contentType="text/html; charset=iso-8859-1" language="java" %>
<%@ taglib uri="/WEB-INF/lib/struts-bean.tld" prefix="bean"%>
<%@ taglib uri="/WEB-INF/lib/struts-html.tld" prefix="html"%>
<%@ taglib uri="/WEB-INF/lib/struts-logic.tld" prefix="logic"%>
<%@ taglib uri="/WEB-INF/lib/vSys.tld" prefix="vsys"%>
<%@ taglib uri="/WEB-INF/lib/c.tld" prefix="c"%>

<script>
function submitForm(opr){
	document.vehicleConsultationForm.opr.value = opr;
	document.vehicleConsultationForm.submit();
}

function consult(){
	document.vehicleConsultationForm.opr.value = 'consulta';
	document.vehicleConsultationForm.submit();
}
</script>


<html:form action="/vehicleConsultation">
	<html:hidden property="opr" />

		<table border="0" width="100%">
		<tr>
			<td>
				<table border="0" width="100%">
					<tr>
						<td width="65%">
							<bean:message key="vehicle.labels.plate"/>:<br />
							<html:text property="plate"/>
						</td>
						<td width="35%">
							<bean:message key="vehicle.labels.vehicle"/> ID:<br />
							<html:text property="vehicleId"/>
						</td>
					</tr>
				</table>
			</td>
		</tr>
		<tr>
			<td>
				<table border="0" width="100%">
					<tr>
						<td width="65%">
							<bean:message key="vehicle.labels.value"/>:<br />
							De <html:text property="initValue" size="10" maxlength="10"/> at&eacute; <html:text property="endValue" size="10" maxlength="10"/>
						</td>
						<td width="35%">
							<bean:message key="vehicle.labels.year"/>:<br />
							De <html:text property="initYear" maxlength ="4" size="4"/> at&eacute; <html:text property="endYear" maxlength ="4" size="4"/>
						</td>
					</tr>
				</table>
			</td>
		</tr>
		<tr>
			<td>
				<table width="100%">
					<tr>

						<td width="65%"><bean:message key="vehicle.labels.city"/>:<br />
							<html:text property="city" maxlength="50" size="40" />
						</td>
						<td width="35%"><bean:message key="vehicle.labels.state"/>:<br />
							<html:text property="state" maxlength="2" size="2" />
						</td>
					</tr>

				</table>
			</td>

		</tr>
		<tr>
			<td>
				<table width="100%">
					<tr>
						<td width="20%"><bean:message key="vehicle.labels.brand"/>:<br />
							<html:select property="selectedBrand" onchange="submitForm('changeModel')" >
								<html:option value="">&nbsp;</html:option>
								<html:options collection="brandsCollection" property="id" labelProperty="brand" />
							</html:select>							
						</td>
						<td width="20%"><bean:message key="vehicle.labels.model"/>:<br />
														
								<html:select property="selectedModel">
									<html:option value="">&nbsp;</html:option>
									<logic:present name="modelsCollection">
										<html:options collection="modelsCollection" property="id" labelProperty="model"/>
									</logic:present>
								</html:select>
							
							
						</td>
						<td width="20%"><bean:message key="vehicle.labels.fuel"/>:<br />
							<html:select property="selectedFuel">
								<html:option value="">&nbsp;</html:option>
								<html:options collection="fuelsCollection" property="id" labelProperty="fuel" />
							</html:select>
							
						</td>
						<td width="20%"><bean:message key="vehicle.labels.color"/>:<br />
							<html:select property="selectedColor">
								<html:option value="">&nbsp;</html:option>
								<html:options collection="colorsCollection" property="id" labelProperty="color" />
							</html:select>
		
						</td>
						<td width="20%"><bean:message key="vehicle.labels.type"/>:<br />
							<select name="type">
								<option value="-1">&nbsp;</option>
								<option value="1">Passeio</option>
								<option value="2">Utilitario</option>
								<option value="3">Pick-up</option>
							</select>
						</td>
					</tr>
				</table>
			</td>
		</tr>
		<tr>
		 	<td>
				<table width="100%">
					<tr>
						<td width="100%" align="center">
								<a href="javascript:consult()"><bean:message key="vehicle.labels.consulate"/></a>
						</td>
						<td widht="100%" align="center">
								<a href="javascript:history.go(-1)"><bean:message key="vehicle.labels.back"/></a>
					</tr>
				</table>
		 	</td>
		</tr>
	</table>
</html:form>	
	
<table width="100%" style="border: 1px solid #969696;" cellpadding="0" cellspacing="0">
	<tr style="background-color: #969696; height: 20px; font-weight: bold;">
		<td>&nbsp;</td>	
		<td width="15%"><bean:message key="vehicle.labels.plate" /></td>
		<td width="10%"><bean:message key="vehicle.labels.year" /></td>
		<td width="15%"><bean:message key="vehicle.labels.value" /></td>
		<td width="10%"><bean:message key="vehicle.labels.brand" /></td>
		<td width="10%"><bean:message key="vehicle.labels.model" /></td>
		<td width="10%"><bean:message key="vehicle.labels.color" /></td>
		<td width="15%"><bean:message key="vehicle.labels.fuel" /></td>
		<td width="13%">Situação</td>
		<td>&nbsp;</td>
	</tr>
	
	
	<logic:present name="vehiclesCollection">
	
		<logic:iterate id="vehicle" name="vehiclesCollection" >
	
		<c:choose>
			<c:when test="${color == '#f3f2f2'}">
				<c:set var="color" value="#e7e6e6" scope="page"/>
			</c:when>
			<c:otherwise>
				<c:set var="color" value="#f3f2f2" scope="page"/>
			</c:otherwise>
		</c:choose>
		
			<tr style="background-color: <c:out value="${color}" />; height: 15px;">
				<td>&nbsp;</td>
				<td><bean:write name="vehicle" property="plate"/></td>
				<td><bean:write name="vehicle" property="year"/></td>
				<td><bean:write name="vehicle" property="value"/></td>
				<td><bean:write name="vehicle" property="model.brand.brand"/></td>
				<td><bean:write name="vehicle" property="model.model"/></td>
				<td><bean:write name="vehicle" property="color.color"/></td>
				<td><bean:write name="vehicle" property="fuel.fuel"/></td>
				<td><a href="moviment.do?opr=view&plate=<bean:write name="vehicle" property="plate"/>">
						<img src="resources/editar_tr.gif" border="0" alt="Editar Veiculo"/></a></td>
				<td>&nbsp;</td>
			</tr>
		
		</logic:iterate>
	</logic:present>
	
	</table>